<template>
    <div class="mui-numbox">
        <!-- "-"按钮，点击可减小当前数值 -->
        <button class="mui-btn mui-numbox-btn-minus"  data-numbox-min="1" type="button">-</button>
        <input value="1" ref="numbox" @change="countChanged" class="mui-input-numbox" type="number" />
        <!-- "+"按钮，点击可增大当前数值 -->
        <button class="mui-btn mui-numbox-btn-plus" type="button">+</button>
    </div>
</template>

<script>
    import mui from '../../lib/mui/js/mui.min.js'
    export default {

        created() {

        },
        mounted() {
            mui(".mui-numbox").numbox().setOption('min',1)
        },
        methods: {
            countChanged(){

                this.$emit("getCount",parseInt(this.$refs.numbox.value))

            }
        },
        props:['max'],
        watch: {
            max: function(newValue,oldValue){

                mui(".mui-numbox").numbox().setOption('max',newValue)
            }
        }
    }

</script>

<style lang="scss" scoped>

</style>